using System;
using System.Collections.Generic;
using System.Text;
using Entities;
using DAL;
using Utility;

namespace BUS
{
   public  class tbCTDonHangBUS
   {
       public static void Insert(tbCTDonHang ctdh)
       {
           tbCTDonHangDAL ctdhDAL = new tbCTDonHangDAL();
           ctdhDAL.Insert(ctdh);
       }
       public static void Update(tbCTDonHang ctdh)
       {
           tbCTDonHangDAL ctdhDAl = new tbCTDonHangDAL();
           ctdhDAl.Update(ctdh);
       }
       public static void Delete(int iD)
       {
           tbCTDonHangDAL ctdhDAl = new tbCTDonHangDAL();
           ctdhDAl.Delete(iD);
       }
       public static tbCTDonHangCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
       {
           tbCTDonHangDAL ctdhDAL = new tbCTDonHangDAL();
           return ctdhDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
       }
       public static tbCTDonHangCollection GetAll()
       {
           int total = 0;
           Criteria cri = new Criteria();
           tbCTDonHangDAL ctdhDAL = new tbCTDonHangDAL();
           return ctdhDAL.Get(cri.Criter, 0, 0, tbCTDonHangColumns.MaCTDH.ToString(), OrderDirection.ASC.ToString(), out total);
       }
       public static tbCTDonHang GetByID(int iD)
       {
           int total = 0;
           Criteria cri = new Criteria();
           cri.add(Condition.AND, tbCTDonHangColumns.MaCTDH.ToString(), Condition.EQUAL, iD);
           tbCTDonHangDAL ctdhDAL = new tbCTDonHangDAL();
           tbCTDonHangCollection ctdhCollection = ctdhDAL.Get(cri.Criter, 0, 0, tbCTDonHangColumns.MaCTDH.ToString(), OrderDirection.ASC.ToString(), out total);
           if (ctdhCollection.Count > 0)
               return ctdhCollection[0];
           return null;
       }
       public static tbCTDonHangCollection GetLimited(int number)
       {
           int total = 0;
           Criteria cri = new Criteria();
           tbCTDonHangDAL ctdhDAL = new tbCTDonHangDAL();
           return ctdhDAL.Get(cri.Criter, 1, number, tbCTDonHangColumns.MaCTDH.ToString(), OrderDirection.DESC.ToString(), out total);
       }
       public static tbCTDonHangCollection GetPromotion(int number)
       {
           int total = 0;
           Criteria cri = new Criteria();
           tbCTDonHangDAL ctdhDAL = new tbCTDonHangDAL();
           return ctdhDAL.Get(cri.Criter, 1, number, tbCTDonHangColumns.MaCTDH.ToString(), OrderDirection.DESC.ToString(), out total);
       }
   }
}